package com.slg.android.manyanime.adapter;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.slg.android.manyanime.bean.Comment;
import com.slg.android.manyanime.fragment.HotCommentFragment;
import com.slg.android.manyanime.fragment.LastCommentFragment;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by E540 on 2015/3/13.
 */
public class CommentFragmentAdapter extends FragmentPagerAdapter {
    private List<Fragment> fragments;
    private String lastData;
    private String hotData;
    private String mid;
    private String type;


    public CommentFragmentAdapter(FragmentManager fm, String lastData, String hotData,String mid,String type) {
        super(fm);
        fragments = new ArrayList<>();
        this.lastData = lastData;
        this.hotData = hotData;
        fragments.add(new LastCommentFragment());
        fragments.add(new HotCommentFragment());
        this.mid = mid;
        this.type = type;
    }

    @Override
    public Fragment getItem(int position) {

        Fragment fragment = fragments.get(position);
        Bundle bundle = new Bundle();
        bundle.putString("mid",mid);
        bundle.putString("type",type);
        if (position == 0) {
            bundle.putString("data", lastData);
        } else {
            bundle.putString("data", hotData);
        }
        fragment.setArguments(bundle);
        return fragment;
    }

    @Override
    public int getCount() {
        return fragments.size();
    }
}
